package com.refusea.train.controller

import com.refusea.train.domain.entity.Course
import com.refusea.train.domain.helper.CourseHelper
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author Zhang Yan 2024/4/3
 **/
@RestController
@RequestMapping("/api/private/course")
class CourseController(private val courseHelper: CourseHelper) {

    @GetMapping("/list")
    fun list(): List<Course> {
        return courseHelper.list()
    }

    @GetMapping("/valid")
    fun valid(): List<Course> {
        return courseHelper.valid()
    }


    @PostMapping("/save")
    fun save(@RequestBody course: Course): Int {
        return courseHelper.save(course)
    }

    @GetMapping("/visible")
    fun visible(id: Int, visible: Boolean) {
        courseHelper.visible(id, visible)
    }


}
